﻿#ifndef FFMPEGPROCESS_H
#define FFMPEGPROCESS_H

#include <QObject>
#include <QProcess>
#include <QStringList>

class FFmpegProcess : public QObject
{
    Q_OBJECT
public:
    explicit FFmpegProcess(QObject *parent = nullptr);

    void start(const QStringList& argList);

private slots:
    void onReadData();

    void onfinished(int exitCode, QProcess::ExitStatus exitStatus);

signals:
    void finished(int exitCode, QProcess::ExitStatus exitStatus);

    void onProgress(double percent);

private:
    static qint64 timeStrToMillisecond(const QString& hhmmss);

private:
    QProcess m_process;
    QStringList m_ffmpegLogs; // ffmpeg log, used for resovle problems
    qint64 m_durationMS = 0; // Video duration in minisecond
};

#endif // FFMPEGPROCESS_H
